var Adv_skd=require("./Adv_skd")

var e = require;
var t = module;
var o = exports;
var n,
    i = o,
    a = e("TreasureChestBox").TreasureBox,
    r = e("Interstitial").InterstitialType,
    s =
        ((n = function (e, t) {
            return (n =
                Object.setPrototypeOf ||
                ({__proto__: []} instanceof Array &&
                    function (e, t) {
                        e.__proto__ = t;
                    }) ||
                function (e, t) {
                    for (var o in t) t.hasOwnProperty(o) && (e[o] = t[o]);
                })(e, t);
        }),
        function (e, t) {
            function o() {
                this.constructor = e;
            }
            n(e, t), (e.prototype = null === t ? Object.create(t) : ((o.prototype = t.prototype), new o()));
        }),
    c = function (e, t, o, n) {
        var i,
            a = arguments.length,
            r = a < 3 ? t : null === n ? (n = Object.getOwnPropertyDescriptor(t, o)) : n;
        if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(e, t, o, n);
        else
            for (var s = e.length - 1; s >= 0; s--)
                (i = e[s]) && (r = (a < 3 ? i(r) : a > 3 ? i(t, o, r) : i(t, o)) || r);
        return a > 3 && r && Object.defineProperty(t, o, r), r;
    };
Object.defineProperty(i, "__esModule", {value: !0});
var l = e("ADConfigs"),
    d = e("AssetsMap"),
    u = e("BundleNames"),
    p = e("ListView"),
    h = e("ConfigGameData"),
    f = e("GameData"),
    _ = e("TaskData"),
    y = e("RankProxy"),
    m = e("RankProxy2"),
    g = cc._decorator,
    v = g.ccclass,
    w = g.property,
    b = (function (e) {
        function t() {
            var t = (null !== e && e.apply(this, arguments)) || this;
            return (
                (t.now_label_tip = null),
                (t.old_label_tip = null),
                (t.btn_back = null),
                (t.btn_play = null),
                (t.RewardBoxParent = null),
                (t.btn_shareRecorder = null),
                (t.listView = null),
                (t.isOppoView = !1),
                t
            );
        }
        return (
            s(t, e),
            (t.prototype.onLoad = function () {
                this.isCache = !1;
            }),
            (t.prototype.start = function () {
                ad.curr_platform == window.ad.Platform.TOU_TIAO && ad.adInterface.hideBanner(!0),
                    ad.curr_platform == window.ad.Platform.TOU_TIAO && ad.adInterface.showInterstitial(),
                    ad.curr_platform == window.ad.Platform.TOU_TIAO && ad.adInterface.showBanner(),
                    ad.curr_platform == window.ad.Platform.WECHAT && ad.adInterface.hideBanner(!0),
                    ad.curr_platform == window.ad.Platform.WECHAT && ad.adInterface.showInterstitial(),
                    ad.curr_platform == window.ad.Platform.WECHAT && ad.adInterface.showBanner(),
                    ad.curr_platform == window.ad.Platform.QQ && ad.adInterface.hideBanner(!0),
                    ad.curr_platform == window.ad.Platform.QQ && ad.adInterface.hideBlock(!0),
                    ad.curr_platform == window.ad.Platform.QQ && ad.adInterface.showBanner(),
                    ad.curr_platform == window.ad.Platform.QQ && ad.adInterface.showInterstitial(),
                    ad.curr_platform == window.ad.Platform.QQ && ad.adInterface.showBlock({top: 50, left: 50}),
                    ad.curr_platform == window.ad.Platform.VIVO
                        ? (ad.adInterface.hideBanner(!1),
                          ad.adInterface.hideNativeBanner(!1),
                          ad.adInterface.isNativeInterstitialAdReady()
                              ? ad.adInterface.showNativeInterstitial()
                              : ad.adInterface.showInterstitial())
                        : ad.curr_platform == window.ad.Platform.MEI_ZU
                        ? ad.adInterface.showInterstitial()
                        : ad.curr_platform == window.ad.Platform.HUAWEI_GAME && ad.adInterface.showNativeInterstitial(),
                    ad.curr_platform == window.ad.Platform.BAI_DU && ad.adInterface.showBanner();
            }),
            (t.prototype.showBoxAd = function () {
                console.log("------------设置宝箱广告---------"),
                    cc.SDK.showBoxVideo(
                        function (e, t) {
                            if (e == a.COIN) {
                                var o = f.default.instance.getPlayerCoin();
                                f.default.instance.setPlayerCoin(o + t);
                            } else a.DIAMONDS;
                        },
                        function () {
                            cc.SDK.showGetUICoinBox(
                                function (e) {
                                    var t = f.default.instance.getPlayerCoin();
                                    f.default.instance.setPlayerCoin(t + e);
                                },
                                function () {},
                                cc.SDK.gameID
                            );
                        },
                        cc.SDK.gameID
                    );
            }),
            (t.prototype.onDisable = function () {
                cc.SDK.hideInterstitial(),
                    ad.curr_platform == window.ad.Platform.WECHAT && ad.adInterface.hideBanner(!1),
                    ad.curr_platform == window.ad.Platform.QQ && ad.adInterface.hideBanner(!1),
                    ad.curr_platform == window.ad.Platform.QQ && ad.adInterface.hideBlock(!1),
                    ad.curr_platform == window.ad.Platform.BAI_DU && ad.adInterface.hideBanner(!1),
                    ad.curr_platform == window.ad.Platform.OPPO && ad.adInterface.hideNativePatch(!1);
            }),
            (t.prototype.onEnable = function () {
                cc.SDK.showInterstitial(r.INTERSTITIAL_GAME_OVER), this.showBoxAd();
            }),
            (t.prototype.onResetView = function () {
                e.prototype.onResetView.call(this);
                var t = ad.curr_platform === window.ad.Platform.TOU_TIAO;
                f.default.instance.GameModel === f.GameModel.endless &&
                    (game.log("T=> 结算无尽模式"), t && window.tt.reportAnalytics("Moshi_WuJin_End", {})),
                    f.default.instance.GameModel === f.GameModel.eatChicken &&
                        (game.log("T=> 乱斗模式结算"), t && window.tt.reportAnalytics("Moshi_LuanDou_End", {})),
                    this.init();

                    Adv_skd.default.instance.hideAllAdv();
                    Adv_skd.default.instance.showInterstitialAd();
                    Adv_skd.default.instance.showGridAdLeft();
            }),
            (t.prototype.init = function () {
                ad.curr_platform == window.ad.Platform.TOU_TIAO
                    ? ((this.btn_back.width = 300),
                      (this.btn_back.height = 80),
                      this.btn_back.setPosition(cc.v3(180, -65, 0)),
                      (this.btn_back.getChildByName("btn_back_bg").active = !0),
                      (this.btn_back.getChildByName("label_back").color = new cc.Color().fromHEX("#B26C39")),
                      (this.btn_back.getChildByName("label_back").getComponent(cc.Label).fontSize = 30),
                      (this.btn_back.getChildByName("label_back").getComponent(cc.Label).lineHeight = 30),
                      this.btn_play.setPosition(cc.v3(-180, -65, 0)),
                      "" != ad.adInterface.ttGetRecordVideoPath() &&
                          game.PopupManager.instance.showPopView(d.default.PopupMap.TTShareRecorderView, null, !0, !1))
                    : ad.curr_platform == window.ad.Platform.OPPO &&
                      ad.adInterface.isNativePatchReady() &&
                      ((this.listView.node.x = -400), ad.adInterface.showNativePatch("NativePatch_1")),
                    null != f.default.instance.OldUserSkin &&
                        ((f.default.instance.UserSkin = f.default.instance.OldUserSkin),
                        (f.default.instance.OldUserSkin = null));
                var e = "无";
                f.default.instance.GameModel == f.GameModel.endless
                    ? (e = f.default.instance.HighestScoreInHistory_endless)
                    : f.default.instance.GameModel == f.GameModel.eatChicken
                    ? (e = f.default.instance.HighestScoreInHistory_shooting)
                    : f.default.instance.GameModel == f.GameModel.TimeLimit &&
                      (e = f.default.instance.HighestScoreInHistory_TimeLimit);
                var t = f.default.instance.SelfPlayerData;
                this.isOppoView
                    ? ((this.now_label_tip.getComponent(cc.Label).string = "" + t.fraction.toString()),
                      (this.old_label_tip.getComponent(cc.Label).string = "" + e))
                    : ((this.now_label_tip.getComponent(cc.Label).string = "本轮分数：" + t.fraction.toString()),
                      (this.old_label_tip.getComponent(cc.Label).string = "历史最高分数：" + e)),
                    _.default.instance.collectPlayerFractionData(t.fraction);
                for (var o = [], n = 0; n < _.default.instance.task_list_index.length; n++) {
                    var i = _.default.instance.task_list_index[n];
                    _.default.instance.getTaskProgressByIndex(i) < 1 && o.push(i);
                }
                for (n = 0; n < _.default.instance.task_list_index.length; n++)
                    (i = _.default.instance.task_list_index[n]),
                        _.default.instance.getTaskProgressByIndex(i) >= 1 && o.push(i);
                if (
                    (this.listView.refreshHandler(o, this.itemRenderHandler, this),
                    (f.default.instance.gameState = f.GameState.finish),
                    f.default.instance.GameModel == f.GameModel.TimeLimit
                        ? t.fraction >= Number(e) - 10 &&
                          game.appFacade.retrieveProxy(m.default.NAME).reportRankData(Number(e))
                        : f.default.instance.GameModel == f.GameModel.endless &&
                          t.fraction >= Number(e) - 10 &&
                          game.appFacade.retrieveProxy(y.default.NAME).reportRankData(Number(e)),
                    f.default.instance.GameModel == f.GameModel.TimeLimit)
                ) {
                    var a = f.default.instance.getPlayerCoin();
                    f.default.instance.setPlayerCoin(a + 10),
                        (this.RewardBoxParent.children[0].x = 0),
                        (this.RewardBoxParent.children[1].active = !1);
                } else if (f.default.instance.GameModel == f.GameModel.endless) {
                    var r = f.default.instance.getPlayerEgg();
                    f.default.instance.setPlayerEgg(r + 1),
                        (this.RewardBoxParent.children[0].active = !1),
                        (this.RewardBoxParent.children[1].x = 0);
                } else
                    f.default.instance.GameModel == f.GameModel.eatChicken &&
                        ((a = f.default.instance.getPlayerCoin()),
                        f.default.instance.setPlayerCoin(a + 10),
                        (r = f.default.instance.getPlayerEgg()),
                        f.default.instance.setPlayerEgg(r + 1));
            }),
            (t.prototype.addEvent = function () {
                e.prototype.addEvent.call(this),
                    this.btn_back.on(game.EngineEventType.NodeEvent.click, this.onClickBack, this),
                    this.btn_play.on(game.EngineEventType.NodeEvent.click, this.onClickAgain, this),
                    this.btn_shareRecorder.on(game.EngineEventType.NodeEvent.click, this.btnClick_shareRecorder, this);
            }),
            (t.prototype.onClickAgain = function () {
                h.default.instance.ResetData(),
                    game.AudioManager.playBtnEffect(),
                    f.default.instance.GameModel == f.GameModel.endless ||
                    f.default.instance.GameModel == f.GameModel.eatChicken
                        ? (f.default.instance.GameModel == f.GameModel.endless &&
                              (f.default.instance.SelfPlayerData.fraction = 0),
                          game.UIManager.instance.replaceModuleView(
                              u.default.Game,
                              d.default.GameBundle.prefabs.assetsList.GameModuleView,
                              {}
                          ))
                        : game.PopupManager.instance.showPopView(d.default.PopupMap.MatchPlayersView, null, !1, !1),
                    this.closeView(!1);

                    Adv_skd.default.instance.hideAllAdv();
            }),
            (t.prototype.onClickBack = function () {
                game.AudioManager.playBtnEffect(),
                    game.UIManager.instance.replaceModuleView(
                        u.default.Start,
                        d.default.StartBundle.prefabs.assetsList.StartModuleView
                    ),
                    ad.curr_platform == window.ad.Platform.OPPO ||
                        (ad.curr_platform == window.ad.Platform.MEI_ZU
                            ? ad.adInterface.showInterstitial()
                            : ad.curr_platform == window.ad.Platform.HUAWEI_GAME &&
                              ad.adInterface.showNativeInterstitial());
            }),
            (t.prototype.removeEvent = function () {
                e.prototype.removeEvent.call(this),
                    this.btn_back.off(game.EngineEventType.NodeEvent.click, this.onClickBack, this),
                    this.btn_play.off(game.EngineEventType.NodeEvent.click, this.onClickAgain, this),
                    this.btn_shareRecorder.off(game.EngineEventType.NodeEvent.click, this.btnClick_shareRecorder, this);
            }),
            (t.prototype.itemRenderHandler = function (e, t) {
                (e.getChildByName("label_name").getComponent(cc.Label).string = _.default.instance.task_list[t]),
                    (e.getChildByName("progress").getComponent(cc.ProgressBar).progress =
                        _.default.instance.getTaskProgressByIndex(t)),
                    1 == _.default.instance.getTaskProgressByIndex(t)
                        ? ((e.getChildByName("label_finish").getComponent(cc.Label).string = "已完成"),
                          (e.getChildByName("label_finish").color = new cc.Color(161, 254, 62)),
                          (e.getChildByName("label_name").color = new cc.Color(161, 254, 62)))
                        : ((e.getChildByName("label_finish").getComponent(cc.Label).string = "未完成"),
                          (e.getChildByName("label_finish").color = new cc.Color(255, 255, 255)),
                          (e.getChildByName("label_name").color = new cc.Color(255, 255, 255)));
            }),
            (t.prototype.btnClick_shareRecorder = function () {
                var e = ad.adInterface.ttGetRecordVideoPath();
                if (e.length < 1) game.UIManager.instance.showToast("录屏失败，请稍后再试");
                else {
                    var t = {
                        share_title: l.TTParam.share_title,
                        videoPath: e,
                        success: function () {},
                        fail: function () {},
                        complete: function () {}
                    };
                    ad.adInterface.ttShareVideo(t);
                }
            }),
            c([w(cc.Node)], t.prototype, "now_label_tip", void 0),
            c([w(cc.Node)], t.prototype, "old_label_tip", void 0),
            c([w(cc.Node)], t.prototype, "btn_back", void 0),
            c([w(cc.Node)], t.prototype, "btn_play", void 0),
            c([w(cc.Node)], t.prototype, "RewardBoxParent", void 0),
            c([w(cc.Node)], t.prototype, "btn_shareRecorder", void 0),
            c([w(p.default)], t.prototype, "listView", void 0),
            c([w(cc.Boolean)], t.prototype, "isOppoView", void 0),
            c([v], t)
        );
    })(game.BasePopView);
i.default = b;
